<template>
    <view class="info-list">
        <view class="stats-info" v-if="totalCount">
            <text class="stats-text">共<text class="stats-number">{{ totalCount }}</text>条{{ dataForm.title }}信息</text>
        </view>
        <view class="info-item" :class="{'is-icon':dataForm.title == '专利'}" v-for="(item, index) in resData" :key="index">
            <!-- 非特殊样式 -->
            <template v-if="dataForm.title != '税务评级'">
                <view class="info-item-title" v-if="dataForm.title == '客户' || dataForm.title == '司法拍卖'">
                    {{ item.ename ? item.ename : '—' }}
                </view>
                <view class="info-item-form" :class="{'is-line':dataForm.title == '专利'}">
                    <view :class="{ 'form-label': ele.type == 'label', 'form-value': ele.type == 'key' }"
                        v-for="(ele, dix) in newData" :key="dix">
                        {{ ele.type == 'label' ? ele.value ? ele.value : '—' : item[ele.value] ? item[ele.value] : '—' }}
                    </view>
                </view>
            </template>
            <!-- 特殊样式（税务评级） -->
            <template v-else>
                <div class="level-container">
                    <div class="level-container-item">
                        <div class="level-icon">
                            <image src="../../../../assets/image/date_icon.png" mode="aspectFit"></image>
                        </div>
                        <div class="level-info">
                            <div class="level-label">评级年度</div>
                            <div class="level-year">{{ item.year }}</div>
                        </div>
                    </div>
                    <div class="level-container-item">
                        <div class="level-icon">
                            <image src="../../../../assets/image/leave_icon.png" mode="aspectFit"></image>
                        </div>
                        <div class="level-info">
                            <div class="level-label">信用级别</div>
                            <div class="level-year">优级</div>
                        </div>
                    </div>
                </div>
            </template>
        </view>
    </view>

</template>

<script>
export default {
    data() {
        return {
            newData: [],
        }
    },
    props: {
        dataForm: {
            type: Object,
            default: []
        },
        resData: {
            type: Object,
            default: []
        },
        totalCount:{
            type:Number,
            default:0
        }
    },
    watch: {
        dataForm(arr) {
            const arr_0 = arr.form;
            let arr_1 = [];
            arr_0.forEach((ele) => {
                arr_1.push({ type: 'label', value: ele.label });
                arr_1.push({ type: 'key', value: ele.key });
            })
            this.newData = arr_1;
        }
    }
}
</script>

<style lang="scss" scoped>
.info-list {
    width: 750rpx;
    padding: 0 23rpx;
    box-sizing: border-box;
    .stats-info {
        padding: 35rpx 0 8rpx 23rpx;
        .stats-text {
            font-family: 'Alibaba PuHuiTi', sans-serif;
            font-weight: 400;
            font-size: 24rpx;
            color: #2B6FEA;

            .stats-number {
                color: #FF0000;
                margin: 0 10rpx;
            }
        }
    }
    .info-item {
        width: 100%;
        background: #FFFFFF;
        border-radius: 20rpx;
        padding: 30rpx 43rpx;
        box-sizing: border-box;
        margin-top: 22rpx;

        &-title {
            font-family: PingFang SC;
            font-weight: 400;
            font-size: 30rpx;
            color: #000000;
            line-height: 39rpx;
            margin-bottom: 20rpx;
        }

        &-form {
            display: grid;
            grid-template-columns: auto 1fr;
            /* 第一列自适应，第二列铺满剩余空间 */
            gap: 5rpx 20rpx;

            /* 可选，设置网格间距 */
            .form-left,
            .form-right {
                display: flex;
                flex-direction: column;
            }

            .form-label {
                font-family: PingFang SC;
                font-weight: 400;
                font-size: 24rpx;
                color: #9B9B9B;
                line-height: 39rpx;
                display: flex;
                flex-direction: column;
            }

            .form-value {
                font-family: PingFang SC;
                font-weight: 400;
                font-size: 24rpx;
                color: #000000;
                line-height: 39rpx;
                display: flex;
                flex-direction: column;
            }
        }
        .is-line{
            display: grid;
            grid-template-columns: 1fr!important;
            /* 第一列自适应，第二列铺满剩余空间 */
            row-gap: 5rpx!important;
        }
    }
    .is-icon{
        background: #FFFFFF url('../../../../assets/image/zl_icon.png') right 20rpx top 20rpx no-repeat;
        background-size: 95rpx 95rpx;
    }
    .level-container {
        display: flex;
        align-items: center;

        &-item {
            width: 50%;
            display: flex;
            align-items: flex-start;
            justify-content: space-between;

            .level-icon {
                width: 38rpx;
                height: 38rpx;
                background: #F2F4F8;
                border-radius: 50%;
                display: flex;
                justify-content: center;
                align-items: center;

                image {
                    width: 21rpx;
                    height: 21rpx;
                }
            }

            .level-info {
                width: calc(100% - 50rpx);

                .level-label {
                    font-family: PingFang SC;
                    font-weight: 400;
                    font-size: 24rpx;
                    color: #9B9B9B;
                }

                .level-year {
                    font-family: PingFang SC;
                    font-weight: 400;
                    font-size: 24rpx;
                    color: #010101;
                    line-height: 39rpx;
                }
            }

            &:last-child {
                padding-left: 20rpx;
                box-sizing: border-box;
                border-left: 1rpx solid #F2F4F8;
            }
        }
    }
}
</style>
